package com.yum.ms.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Yum
 * @version 1.0
 *  Topic模式
 */
@Configuration
public class MQTopicConfig {
    public static final String QUEUE = "seckillQueue";
    public static final String EXCHANGE = "seckillExchange";

    // 创建消息队列
    @Bean
    public Queue queue() {
        return new Queue(QUEUE);
    }
    // 创建交换机
    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange(EXCHANGE);
    }
    // 绑定交换机
    @Bean
    public Binding binding() {
        return BindingBuilder.bind(queue()).to(topicExchange()).with("seckill.#");
    }

}
